{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "36a55b58",
   "metadata": {},
   "source": [
    "# 第六周笔记\n",
    "* 一切都是对象！！！一切都是对象！！！一切都是对象  \n",
    "例：“Don't panic!”是个字符串，42是个数字对象  \n",
    "* 对象可以有状态（属性或值）和行为（方法），任何“东西”都可以赋给任何变量，变量可以赋为任何东西。\n",
    "# 内置数据结构\n",
    "* “内置”是指列表、元祖、字典和集合在代码中可以直接使用，使用前无需先导入\n",
    "## 列表  \n",
    "1.是有序的可变对象集合  \n",
    "2.序列中的每个值都有对应的位置值，称之为索引，第一个索引是 0，第二个索引是 1，依此类推。   \n",
    "3.是可变的，可以随时进行增加、删除或修改对象来修改列表  \n",
    "4.列表都可以进行的操作包括索引，切片，加，乘，检查成员。  \n",
    "5.+ 号用于组合列表，* 号用于重复列表。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5b20ed65",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> len([1,2,3]) # 长度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "dbc7942c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[1,2,3]+[4,5,6] # 组合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "51489165",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['hi!', 'hi!', 'hi!', 'hi!']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "['hi!']*4 # 重复"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2fe30257",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3 in [1,2,3] # 元素是否存在列表中"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "20787eba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123"
     ]
    }
   ],
   "source": [
    "for x in [1,2,3]:print(x,end=\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87800623",
   "metadata": {},
   "source": [
    "## 元祖\n",
    "1.是有序的不可变对象集合  \n",
    "2.元组是有多个逗号分隔组成"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cbb6e184",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(12345, 54321, 'hello!')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> t = 12345, 54321, 'hello!'\n",
    ">>> t[0]\n",
    ">>> t"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b5bbbd2",
   "metadata": {},
   "source": [
    "3.元组是可以嵌套的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "49362666",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((12345, 54321, 'hello!'), (1, 2, 3))"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> t = 12345, 54321, 'hello!'\n",
    ">>> u = t, (1, 2, 3)\n",
    ">>> u"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa423b4c",
   "metadata": {},
   "source": [
    "4.元组只有两种方法，count和index"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9dc8e0b",
   "metadata": {},
   "source": [
    "## 字典\n",
    "1.无序数据结构，保持数据有序并不重要，而结构很重要  \n",
    "2.无序的键/值对集合  \n",
    "3.字典的每个键值 key=>value 对用冒号 : 分割，每个对之间用逗号(,)分割，整个字典包括在花括号 {} 中  \n",
    "如：d = {key1 : value1, key2 : value2, key3 : value3 }  \n",
    "4.键必须是唯一的，但值则不必。字符串和数字可以是键\n",
    "5.字典由键索引，它可以是任何不可变类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "44b084b9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3b8d41ce",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "200.2px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
